#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int link[maxn], vis[maxn];
vector<int> g[maxn];

int find(int x) {
	for(int i = 0; i < g[x].size(); i++) {
		int v = g[x][i];
		if(!vis[v]) {
			vis[v] = 1;
			if(link[v] == -1 || find(link[v])) 
				return link[v] = x, 1;
		}
	}
	return 0;
}


int main() {
	memset(link, -1, sizeof(link));
	int n; cin >> n;
	for(int i = 1; i <= n; i++) {
		int x, y; cin >> x >> y;
		g[x].push_back(i);
		g[y].push_back(i);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		memset(vis, 0, sizeof(vis));
		if(find(i)) ans++;
		else break;
	}
	cout << ans << endl;
	return 0;
}
